package com.itheima.demo1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.function.Consumer;

public class CollectionDemo1 {
    public static void main(String[] args) {

       /* Collection<String> coll = new ArrayList<>();
        coll.add("zhangsan");
        coll.add("lisi");
        coll.add("wangwu");

        //利用匿名内部类遍历
        coll.forEach(new Consumer<String>() {
            @Override
            //s依次表示集合中的每一个数据
            public void accept(String s) {
                System.out.println(s);
            }
        });

        //lambda表达式
        coll.forEach(s -> System.out.println(s));*/

        Integer[] arr = {2,3,1,5,6,8,7,9};

        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                System.out.println("--------------------------");
                System.out.println("o1 " + o1);
                System.out.println("o2 " + o2);
                return o1 - o2;
            }
        });

    }
}
